package com.thti.mecool.client.command.result.work;

import com.threeti.mecool.mobile.interfaces.dto.ChannelDto;
import com.thti.mecool.client.base.BaseActivity;
import com.thti.mecool.client.base.Cache;
import com.thti.mecool.client.base.HandlerConstant;
import com.thti.mecool.client.command.ICommand;
import com.thti.mecool.client.model.biz.WorkmemoBizImpl;
import com.thti.mecool.client.protocol.work.GetWorkmemoChannelResult;
import com.thti.mecool.client.service.Protocol;

public class GetWorkmemoChannelCommand implements ICommand{

	@Override
	public void doCommand(Object o) {
		GetWorkmemoChannelResult getWorkmemoChannelResult=(GetWorkmemoChannelResult)o;
		if(getWorkmemoChannelResult!=null){
			if(getWorkmemoChannelResult.getStatus()==1){
				WorkmemoBizImpl workmemoBizImpl=new WorkmemoBizImpl(Cache.getmContext());
				workmemoBizImpl.deleteTable("workmemoChannel");
				for(ChannelDto channelDto:getWorkmemoChannelResult.getChannels()){
					workmemoBizImpl.saveChannel(channelDto);
				}
				BaseActivity.setDataFlag(HandlerConstant.getChannelCommand);
			}else{
				BaseActivity.setFailName("备忘终端");
				BaseActivity.setCurrentMesg(getWorkmemoChannelResult.getMsg());
				BaseActivity.setDataFlag(HandlerConstant.CommandFail);
				}
		}
		}

	@Override
	public String getCommandID() {
		return Protocol.getChannel;
	}

	@Override
	public Class<?> getCommandClass() {
		return GetWorkmemoChannelResult.class;
	}

}
